package com.study.firstline.utils

import android.app.Activity

/**
 *
 *  @author hexiao
 *  @date  2023/3/10 15:00
 *  @package com.study.firstline.utils
 *  @project FirstLineCodeApp
 *  @desc
 */
object ActivityCollector {
    private val activities=ArrayList<Activity>();

    /**
     * 添加Activity
     */
    fun addActivity(activity: Activity){
        activities.add(activity);
    }

    /**
     * 移除Activity
     */
    fun removeActivity(activity: Activity){
        activities.remove(activity);
    }

    /**
     * 关闭所有的Activity
     */
    fun finishAll(){
        for (activity in activities) {
            if(!activity.isFinishing){
                activity.finish();
            }
        }
        activities.clear();
    }

}